﻿using System;
using System.Collections.Generic;
using System.Text;
using Portal.Common.Interface;
using Portal.Common.Entity;
using System.Collections;

namespace Portal.Logic
{
    class PersonSettingLogic:IPersonSetting
    {

        public List<PersonSettingEntity> GetListByUserId(string userId)
        {
            Hashtable ht = new Hashtable();
            ht.Add("userCode", userId);
            return DataHelper.Instance().GetList<PersonSettingEntity>("PersonSettingLogic_GetListByUser", ht);
        }



        public int DeleteByParams(string items, string value)
        {
            Hashtable ht = new Hashtable();
            ht.Add("item", items);
            ht.Add("value", value);
            return DataHelper.Instance().Delete("PersonSettingLogic_DeleteByParams", ht);
           
        }



        public void InserData(PersonSettingEntity entity)
        {
            Hashtable ht = new Hashtable();
            ht.Add("ID", Guid.NewGuid().ToString());
            ht.Add("USER_ID", entity.USER_ID);
            ht.Add("SETTING_ITEMS", entity.SETTING_ITEMS);
            ht.Add("SETTING_VALUE", entity.SETTING_VALUE);
            ht.Add("SETTING_TYPE", entity.SETTING_TYPE);
            ht.Add("CREATE_DATE", entity.CREATE_DATE);
            ht.Add("CREATE_BY", entity.CREATE_BY);
            ht.Add("UPDATE_DATE", entity.UPDATE_DATE);
            ht.Add("UPDATE_BY", entity.UPDATE_BY);
            ht.Add("IS_ACTIVE", entity.IS_ACTIVE);
            ht.Add("DELEGATOR_STATUS", entity.DELEGATOR_STATUS);
            ht.Add("SETTING_SORT", entity.SETTING_SORT);
            ht.Add("EXT01", entity.EXT01);
            DataHelper.Instance().Insert("PersonSettingLogic_InsertData", ht);
        }


        public int DeleteById(string id)
        {
            Hashtable ht = new Hashtable();
            ht.Add("str", id);
            return (int)DataHelper.Instance().Delete("PersonSettingLogic_DeleteById", ht);
        }


        public List<PersonSettingEntity> GetById(string id)
        {
            Hashtable ht = new Hashtable();
            ht.Add("ID", id);
            return DataHelper.Instance().GetList<PersonSettingEntity>("PersonSettingLogic_GetById", ht);
        }

        /// <summary>
        /// 根据ID更新常用意见及附言
        /// </summary>
        /// <param name="Id"></param>
        /// <param name="msg"></param>
        /// <returns></returns>
        public int UpdateMsgById(string Id,string msg)
        {
            Hashtable ht = new Hashtable();
            ht.Add("ID", Id);
            ht.Add("msg", msg);
            return (int)DataHelper.Instance().Update("PersonSettingLogic_UpdateMsgById", ht);

        }
    }
}
